"use strict";

$(document).ready(function () {
	/* 封闭作用域 */
	var App = new Vue({
		el: "#vue-contaniner",
		data: function data() {
			return {
				/* 当前订单数量 1 2 7 6 3 4 5*/
				orderName: [{ name: '总订单', index: "1" }, { name: '待发货', index: "2" }, { name: '待续租', index: "7" }, { name: '待归还', index: "6" }, { name: '待结算', index: "3" }, { name: '待退货', index: "4" }, { name: '成功订单', index: "5" }],
				orderNumber: [],
                borrowOrderName: [{ name: '总订单', index: "1" }, { name: '待发货', index: "2" }, { name: '待归还', index: "3" }, { name: '待结算', index: "4" }, { name: '成功订单', index: "5" }, { name: '逾期订单', index: "6" }, { name: '取消订单', index: "7" }],
                borrowOrderNumber: [],
				data: {
					goods_max_count: 0, //每笔限租
					is_cert: 1, //是否实名认证
					services: [2], //服务标 （数组）
					rent_period_types: {}, //租赁周期 （数组）
					express_model_id: -1, //快递模板ID
					todoor_model_id: -1, //上门模板ID
					since_sites: [], //自提点ID（多个ID用英文逗号拼接）
					return_addrs: [] }, //归还地址
				//首页数据
				freight: [], //快递模板
				freight_door: [], //上门模板
				freight_person: [], //自提模板
				sinceList: [], //归还地址
				currentData: {}, //当前选择数据
				/* 是否为第一次设置数据 0为否，1为是*/
				firstSetting: 0,
				/* 当前数据类型 0:预览状态 1：修改状态*/
				dataType: 0,
				/* 服务标数据列表 */
				serviceList: [{
					name: "免押金",
					click: 0,
					msg: "消费者下单时不需支付商品押金"
				}, {
					name: "包邮",
					click: 0,
					msg: "商品支持选择区域内，寄送的快递费由商家承担，归还的快递费由消费者承担"
				}, {
					name: "免赔",
					click: 0,
					msg: "物品轻微损坏无需赔偿，轻微损坏范围见商家说明"
				}, {
					name: "上门",
					click: 0,
					msg: "商家负责送货上门，同时负责归还上门取货"
				}, {
					name: "自提",
					click: 0,
					msg: "消费者可到商家设置的自提点，进行取货和归还"
				}, {
					name: "随租随还",
					click: 0,
					msg: "租赁的商品提前归还时，只收取实际租赁时间的租金,退还剩余租金"
				}],
				/* 周期表格说明 */
				dateInfo: ["用户需起租的最小周期", "用户可起租的最大周期", "用户最少在起租日前多少天可以下单租赁", "用户最多在起租日前多少月可以下单租赁", "用户续期租赁时租价的折扣"],
				/* 周期map表 */
				dateMap: ["日", "周", "月", "季", "年"],
				/* 周期数据列表 */
				dateList: [{
					name: "日",
					click: 1,
					type: "day",
					data: [5, -1, 5, 12, 100]
				}, {
					name: "周",
					click: 1,
					type: "week",
					data: [1, -1, 5, 12, 100]
				}, {
					name: "月",
					click: 1,
					type: "month",
					data: [1, -1, 5, 12, 100]
				}, {
					name: "季",
					click: 0,
					type: "season",
					data: [1, -1, 5, 12, 100]
				}, {
					name: "年",
					click: 0,
					type: "year",
					data: [1, -1, 5, 12, 100]
				}]
			};
		},
		computed: {
			/* 全选计算属性 */
			allChecks: function allChecks() {
				var self = this;
				var obj = [];
				if (self.freight_person.length <= self.data.since_sites.length) {
					obj[0] = "since";
				} else {
					obj[0] = "";
				}
				if (self.sinceList.length <= self.data.return_addrs.length) {
					obj[1] = "return";
				} else {
					obj[1] = "";
				}
				return obj;
			},
			/* 显示判断，前提条件，处于预览模式下 */
			/* 服务标是否显示，主要判断当前需要显示的三个服务标 */
			serviceShow: function serviceShow() {
				if (this.serviceList[0].click != 1 && this.serviceList[2].click != 1 && this.serviceList[5].click != 1) {
					return false;
				} else {
					return true;
				}
			},
			/* 周期设置是否显示，判断click */
			dateShow: function dateShow() {
				var index = 0;
				var _iteratorNormalCompletion = true;
				var _didIteratorError = false;
				var _iteratorError = undefined;

				try {
					for (var _iterator = this.dateList[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
						var item = _step.value;

						if (item.click == 1) {
							index++;
						}
					}
				} catch (err) {
					_didIteratorError = true;
					_iteratorError = err;
				} finally {
					try {
						if (!_iteratorNormalCompletion && _iterator["return"]) {
							_iterator["return"]();
						}
					} finally {
						if (_didIteratorError) {
							throw _iteratorError;
						}
					}
				}

				if (index == 0) {
					return false;
				} else {
					return true;
				}
			},
			/* 运费是否显示，三个数据合并判断*/
			freightShow: function freightShow() {
				/* 快递运费模板 */
				/* 自提运费模板 */
				/* 上门运费模板 */
				/* express_model_id: -1, //快递模板ID
    todoor_model_id: -1, //上门模板ID
    since_sites: [] */
				if (this.data.express_model_id == -1 && this.data.todoor_model_id == -1 && this.data.since_sites.length == 0) {
					return false;
				} else {
					return true;
				}
			}
		},
		methods: {
			/* 开始设置基本属性 */
			startChange: function startChange() {
				this.dataType = 1;
			},
			/* 初次进入显示设置 */
			showSetting: function showSetting() {
				this.dataType = 1;
			},
			/* 取消编辑状态 */
			cancelSetting: function cancelSetting() {
				this.dataType = 0;
			},
			/* 0 为 自提 1为 归还 */
			allCheck: function allCheck(type) {
				var self = this;
				if (type == 0) {
					if (self.allChecks[0] == "since") {
						self.data.since_sites = [];
					} else {
						self.data.since_sites = [];
						var _iteratorNormalCompletion2 = true;
						var _didIteratorError2 = false;
						var _iteratorError2 = undefined;

						try {
							for (var _iterator2 = self.freight_person[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
								var item = _step2.value;

								self.data.since_sites.push(item.since_id);
							}
						} catch (err) {
							_didIteratorError2 = true;
							_iteratorError2 = err;
						} finally {
							try {
								if (!_iteratorNormalCompletion2 && _iterator2["return"]) {
									_iterator2["return"]();
								}
							} finally {
								if (_didIteratorError2) {
									throw _iteratorError2;
								}
							}
						}
					}
				} else {
					if (self.allChecks[1] == "return") {
						self.data.return_addrs = [];
					} else {
						self.data.return_addrs = [];
						var _iteratorNormalCompletion3 = true;
						var _didIteratorError3 = false;
						var _iteratorError3 = undefined;

						try {
							for (var _iterator3 = self.sinceList[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
								var item = _step3.value;

								self.data.return_addrs.push(item.revert_id);
							}
						} catch (err) {
							_didIteratorError3 = true;
							_iteratorError3 = err;
						} finally {
							try {
								if (!_iteratorNormalCompletion3 && _iterator3["return"]) {
									_iterator3["return"]();
								}
							} finally {
								if (_didIteratorError3) {
									throw _iteratorError3;
								}
							}
						}
					}
				}
			},
			/* 最大租赁数量验证 */
			max: function max(value) {
				var self = this;
				setTimeout(function () {
					if (self.data.goods_max_count === NaN) {
						return false;
					}
					if (self.data.goods_max_count < 0) {
						self.data.goods_max_count = 0;
					} else if (self.data.goods_max_count > 50) {
						self.data.goods_max_count = 50;
					} else {
						self.data.goods_max_count = (self.data.goods_max_count - 0).toFixed(0);
					}
					var data = self.data.goods_max_count;
					self.data.goods_max_count = null;
					self.data.goods_max_count = data;
				}, 100);
			}, /*  */
			percent: function percent(value) {
				var self = this;
				setTimeout(function () {
					if (value === NaN) {
						return false;
					}
					if (value[4] < 0) {
						value[4] = 0;
					} else if (value[4] > 100) {
						value[4] = 100;
					} else {
						value[4] = (value[4] - 0).toFixed(0);
					}
					var data = self.dateList;
					self.dateList = [];
					self.dateList = data;
				}, 100);
			},
			dataMin: function dataMin(item, index) {
				item[index] = 0;
				var obj = this.dateList;
				this.dateList = [];
				this.dateList = obj;
			},
			/* 最大租用周器无限期切换 */
			dataMax: function dataMax(item, index) {
				item[index] = -1;
				var obj = this.dateList;
				this.dateList = [];
				this.dateList = obj;
			},
			/* 服务标选择 */
			serviceClick: function serviceClick(index) {
				if (index != 2) {
					this.serviceList[index - 1].click = 1 - this.serviceList[index - 1].click;
				} else {
					layer.msg("包邮为必选属性");
				}
			},
			/* 日期选择 */
			dataClick: function dataClick(item) {
				if (item.click == 1) {
					item.click = 0;
				} else {
					/* 最多只能选择三个 */
					var flag = 0;
					var _iteratorNormalCompletion4 = true;
					var _didIteratorError4 = false;
					var _iteratorError4 = undefined;

					try {
						for (var _iterator4 = this.dateList[Symbol.iterator](), _step4; !(_iteratorNormalCompletion4 = (_step4 = _iterator4.next()).done); _iteratorNormalCompletion4 = true) {
							var ite = _step4.value;

							if (ite.click == 1) {
								flag++;
							}
						}
					} catch (err) {
						_didIteratorError4 = true;
						_iteratorError4 = err;
					} finally {
						try {
							if (!_iteratorNormalCompletion4 && _iterator4["return"]) {
								_iterator4["return"]();
							}
						} finally {
							if (_didIteratorError4) {
								throw _iteratorError4;
							}
						}
					}

					if (flag == 3) {
						layer.msg("时间周期最多只能选择三个");
					} else {
						item.click = 1;
					}
				}
			},
			/* 获取订单数量 */
			getOrderNumber: function getOrderNumber() {
				var self = this;
				$.ajax({
					url: baseUrl + "api/index/getOrderCount",
					type: "GET",
					data: {},
					async: true,
					dataType: "json",
					success: function success(response) {
						var order = new Array(7);
						/* 1，2，7，6，3，4，5 */
						for (var num = 0; num < order.length; num++) {
							if (num == 6 || num == 4 || num == 5) {
								order[num] = response.data[num - 1];
							} else if (num == 2) {
								order[num] = response.data[7];
							} else if (num == 3) {
								order[num] = response.data[6];
							} else {
								order[num] = response.data[num + 1];
							}
						}
						self.orderNumber = order;
					},
					error: function error(_error) {}
				});
			},
            /* 获取图书订单数量 */
            getBorrowOrderNumber: function getBorrowOrderNumber() {
                var self = this;
                $.ajax({
                    url: baseUrl + "api/index/getBorrowOrderCount",
                    type: "GET",
                    data: {},
                    async: true,
                    dataType: "json",
                    success: function success(response) {
                        var order = new Array(7);
                        /* 1，2，3，4，5 ,6 ,7*/
                        for (var num = 0; num < order.length; num++) {
                            order[num] = response.data[num + 1];
                        }
                        self.borrowOrderNumber = order;
                    },
                    error: function error(_error) {}
                });
            },
			/* 获取首页常规数据 */
			getMainData: function getMainData() {
				/* var data=new Date().getTime(); */
				var self = this;
				$.ajax({
					url: baseUrl + "api/goods/getCommonAttr",
					type: "GET",
					data: {},
					async: true,
					dataType: "json",
					success: function success(response) {
						/* 测试接口返回速度 */
						/* console.log(new Date().getTime()-data); */
						/* 首次完全没有数据 */
						if (response.status == 1) {
							self.data = response.data;
							self.dataRender(self.data);
						} else {
							self.firstSetting = 1;
						}
					},
					error: function error(_error2) {}
				});
			},
			/* 当前订单数据渲染 */
			dataRender: function dataRender(data) {
				/* 日期格式化 */
				var _iteratorNormalCompletion5 = true;
				var _didIteratorError5 = false;
				var _iteratorError5 = undefined;

				try {
					for (var _iterator5 = this.dateList[Symbol.iterator](), _step5; !(_iteratorNormalCompletion5 = (_step5 = _iterator5.next()).done); _iteratorNormalCompletion5 = true) {
						var item = _step5.value;

						item.click = 0;
					}
				} catch (err) {
					_didIteratorError5 = true;
					_iteratorError5 = err;
				} finally {
					try {
						if (!_iteratorNormalCompletion5 && _iterator5["return"]) {
							_iterator5["return"]();
						}
					} finally {
						if (_didIteratorError5) {
							throw _iteratorError5;
						}
					}
				}

				if (JSON.stringify(data.rent_period_types) != "{}") {
					for (var item in data.rent_period_types) {
						var _iteratorNormalCompletion6 = true;
						var _didIteratorError6 = false;
						var _iteratorError6 = undefined;

						try {
							for (var _iterator6 = this.dateList[Symbol.iterator](), _step6; !(_iteratorNormalCompletion6 = (_step6 = _iterator6.next()).done); _iteratorNormalCompletion6 = true) {
								var ite = _step6.value;

								if (ite.type == item) {
									ite.click = 1;
									ite.data = data.rent_period_types[item];
								}
							}
						} catch (err) {
							_didIteratorError6 = true;
							_iteratorError6 = err;
						} finally {
							try {
								if (!_iteratorNormalCompletion6 && _iterator6["return"]) {
									_iterator6["return"]();
								}
							} finally {
								if (_didIteratorError6) {
									throw _iteratorError6;
								}
							}
						}
					}
				}
				/* 服务格式化 */
				if (data.services.length > 0) {
					var _iteratorNormalCompletion7 = true;
					var _didIteratorError7 = false;
					var _iteratorError7 = undefined;

					try {
						for (var _iterator7 = data.services[Symbol.iterator](), _step7; !(_iteratorNormalCompletion7 = (_step7 = _iterator7.next()).done); _iteratorNormalCompletion7 = true) {
							var item = _step7.value;

							this.serviceList[item - 1].click = 1;
						}
					} catch (err) {
						_didIteratorError7 = true;
						_iteratorError7 = err;
					} finally {
						try {
							if (!_iteratorNormalCompletion7 && _iterator7["return"]) {
								_iterator7["return"]();
							}
						} finally {
							if (_didIteratorError7) {
								throw _iteratorError7;
							}
						}
					}
				}
				/* 兼容后端错误数据 */
				if (!data.since_sites) {
					data.since_sites = [];
				}
				if (!data.return_addrs) {
					data.return_addrs = [];
				}
			},
			/* 获取快递模板 */
			getFreight: function getFreight() {
				var self = this;
				$.ajax({
					url: baseUrl + "merchant/goods/refresh_kd",
					type: "GET",
					data: {},
					async: true,
					dataType: "json",
					success: function success(response) {
						if (response.status == 1) {
							/*首先进行数据验证 */
							var trueData = -1;
							var _iteratorNormalCompletion8 = true;
							var _didIteratorError8 = false;
							var _iteratorError8 = undefined;

							try {
								for (var _iterator8 = response.data[Symbol.iterator](), _step8; !(_iteratorNormalCompletion8 = (_step8 = _iterator8.next()).done); _iteratorNormalCompletion8 = true) {
									var ite = _step8.value;

									if (self.data.express_model_id == ite.freight_id) {
										trueData = ite.freight_id;
									}
								}
							} catch (err) {
								_didIteratorError8 = true;
								_iteratorError8 = err;
							} finally {
								try {
									if (!_iteratorNormalCompletion8 && _iterator8["return"]) {
										_iterator8["return"]();
									}
								} finally {
									if (_didIteratorError8) {
										throw _iteratorError8;
									}
								}
							}

							self.data.express_model_id = trueData;
							self.freight = response.data;
						}
					},
					error: function error(_error3) {}
				});
			},
			/* 获取上门快递模板 */
			getFreightDoor: function getFreightDoor() {
				var self = this;
				$.ajax({
					url: baseUrl + "merchant/goods/refresh_sm",
					type: "GET",
					data: {},
					async: true,
					dataType: "json",
					success: function success(response) {
						if (response.status == 1) {
							/*首先进行数据验证 */
							var trueData = -1;
							var _iteratorNormalCompletion9 = true;
							var _didIteratorError9 = false;
							var _iteratorError9 = undefined;

							try {
								for (var _iterator9 = response.data[Symbol.iterator](), _step9; !(_iteratorNormalCompletion9 = (_step9 = _iterator9.next()).done); _iteratorNormalCompletion9 = true) {
									var ite = _step9.value;

									if (self.data.todoor_model_id == ite.freight_id) {
										trueData = ite.freight_id;
									}
								}
							} catch (err) {
								_didIteratorError9 = true;
								_iteratorError9 = err;
							} finally {
								try {
									if (!_iteratorNormalCompletion9 && _iterator9["return"]) {
										_iterator9["return"]();
									}
								} finally {
									if (_didIteratorError9) {
										throw _iteratorError9;
									}
								}
							}

							self.data.todoor_model_id = trueData;
							self.freight_door = response.data;
							self.getFreightPerson();
							self.getSince();
						}
					},
					error: function error(_error4) {}
				});
			},
			/* 获取自提快递模板 */
			getFreightPerson: function getFreightPerson() {
				var self = this;
				$.ajax({
					url: baseUrl + "api/goods/getSinces",
					type: "GET",
					data: {},
					async: true,
					dataType: "json",
					success: function success(response) {
						/* staus为1说明有数据 */
						if (response.status == 1) {
							/*首先进行数据验证 */
							var trueData = [];
							var _iteratorNormalCompletion10 = true;
							var _didIteratorError10 = false;
							var _iteratorError10 = undefined;

							try {
								for (var _iterator10 = self.data.since_sites[Symbol.iterator](), _step10; !(_iteratorNormalCompletion10 = (_step10 = _iterator10.next()).done); _iteratorNormalCompletion10 = true) {
									var item = _step10.value;
									var _iteratorNormalCompletion11 = true;
									var _didIteratorError11 = false;
									var _iteratorError11 = undefined;

									try {
										for (var _iterator11 = response.data[Symbol.iterator](), _step11; !(_iteratorNormalCompletion11 = (_step11 = _iterator11.next()).done); _iteratorNormalCompletion11 = true) {
											var ite = _step11.value;

											if (item == ite.since_id) {
												trueData.push(item);
											}
										}
									} catch (err) {
										_didIteratorError11 = true;
										_iteratorError11 = err;
									} finally {
										try {
											if (!_iteratorNormalCompletion11 && _iterator11["return"]) {
												_iterator11["return"]();
											}
										} finally {
											if (_didIteratorError11) {
												throw _iteratorError11;
											}
										}
									}
								}
							} catch (err) {
								_didIteratorError10 = true;
								_iteratorError10 = err;
							} finally {
								try {
									if (!_iteratorNormalCompletion10 && _iterator10["return"]) {
										_iterator10["return"]();
									}
								} finally {
									if (_didIteratorError10) {
										throw _iteratorError10;
									}
								}
							}

							self.data.since_sites = trueData;
							self.freight_person = response.data;
						}
					},
					error: function error(_error5) {}
				});
			},
			/* 获取归还模板 */
			getSince: function getSince() {
				var self = this;
				$.ajax({
					url: baseUrl + "merchant/revert/getrevert",
					type: "GET",
					data: {},
					async: true,
					dataType: "json",
					success: function success(response) {
						if (response.status == 1) {
							/*首先进行数据验证 */
							var trueData = [];
							var _iteratorNormalCompletion12 = true;
							var _didIteratorError12 = false;
							var _iteratorError12 = undefined;

							try {
								for (var _iterator12 = self.data.return_addrs[Symbol.iterator](), _step12; !(_iteratorNormalCompletion12 = (_step12 = _iterator12.next()).done); _iteratorNormalCompletion12 = true) {
									var item = _step12.value;
									var _iteratorNormalCompletion13 = true;
									var _didIteratorError13 = false;
									var _iteratorError13 = undefined;

									try {
										for (var _iterator13 = response.data[Symbol.iterator](), _step13; !(_iteratorNormalCompletion13 = (_step13 = _iterator13.next()).done); _iteratorNormalCompletion13 = true) {
											var ite = _step13.value;

											if (item == ite.revert_id) {
												trueData.push(item);
											}
										}
									} catch (err) {
										_didIteratorError13 = true;
										_iteratorError13 = err;
									} finally {
										try {
											if (!_iteratorNormalCompletion13 && _iterator13["return"]) {
												_iterator13["return"]();
											}
										} finally {
											if (_didIteratorError13) {
												throw _iteratorError13;
											}
										}
									}
								}
							} catch (err) {
								_didIteratorError12 = true;
								_iteratorError12 = err;
							} finally {
								try {
									if (!_iteratorNormalCompletion12 && _iterator12["return"]) {
										_iterator12["return"]();
									}
								} finally {
									if (_didIteratorError12) {
										throw _iteratorError12;
									}
								}
							}

							self.data.return_addrs = trueData;
							self.sinceList = response.data;
						}
					},
					error: function error(_error6) {}
				});
			},
			/* 数据保存 */
			saveData: function saveData() {
				/* 在进行数据之前，应该判断当前数据是否全部为空，全为空的情况下是否将其状态设置为初次进入 */
				/* 目前方法为不判断，由后端决定用户状态 */
				var self = this;
				var dateObj = {};
				var _iteratorNormalCompletion14 = true;
				var _didIteratorError14 = false;
				var _iteratorError14 = undefined;

				try {
					for (var _iterator14 = this.dateList[Symbol.iterator](), _step14; !(_iteratorNormalCompletion14 = (_step14 = _iterator14.next()).done); _iteratorNormalCompletion14 = true) {
						var item = _step14.value;

						if (item.click == 1) {
							dateObj[item.type] = item.data;
						}
					}
					/* 服务标数据拼接 */
				} catch (err) {
					_didIteratorError14 = true;
					_iteratorError14 = err;
				} finally {
					try {
						if (!_iteratorNormalCompletion14 && _iterator14["return"]) {
							_iterator14["return"]();
						}
					} finally {
						if (_didIteratorError14) {
							throw _iteratorError14;
						}
					}
				}

				var serObj = [];
				for (var item = 0; item < this.serviceList.length; item++) {
					if (this.serviceList[item].click == 1) {
						serObj.push(item + 1);
					}
				}
				/* 周期数据string转int */
				for (var key in dateObj) {
					for (var item in dateObj[key]) {
						dateObj[key][item] -= 0;
					}
				}
				this.data.rent_period_types = dateObj;
				this.data.services = serObj;
				$.ajax({
					url: baseUrl + "api/goods/saveCommonAttr",
					type: "POST",
					data: {
						data: JSON.stringify(self.data)
					},
					async: true,
					dataType: "json",
					success: function success(response) {
						if (response.status == 1) {
							layer.msg("保存成功");
							window.location.reload();
						} else {
							layer.msg("保存失败，请重新尝试");
						}
					},
					error: function error(_error7) {}
				});
			}
		},
		mounted: function mounted() {
			this.getOrderNumber();
            this.getBorrowOrderNumber();
			this.getMainData();
			this.getFreight();
			this.getFreightDoor();
		}
	});

	$(".index_main_typeList").on("mouseover", ".index_main_typeSingle", function () {
		var obj = $(this);
		var msg = $(this).data("msg");
		layer.tips(msg, obj, {
			time: 100000,
			tips: [1, '#2196f3'] //还可配置颜色
		});
	});
	$(".index_main_typeList").on("mouseout", ".index_main_typeSingle", function () {
		layer.closeAll();
	});

	$(".index_main_dateEdit ").on("mouseover", "h3", function () {
		var obj = $(this);
		var msg = $(this).data("msg");
		layer.tips(msg, obj, {
			time: 100000,
			tips: [1, '#2196f3'] //还可配置颜色
		});
	});
	$(".index_main_dateEdit ").on("mouseout", "h3", function () {
		layer.closeAll();
	});
	/* 查找订单月份 */
	var currentMonth = undefined,
	    currentYear = undefined;
	currentMonth = new Date().getMonth() + 1;
	currentYear = new Date().getFullYear();
	$(".currentMonth option").each(function () {
		if ($(this).val() >= currentMonth) {
			$(this).hide();
		}
		if ($(this).val() == currentMonth - 1) {
			$(this).attr("selected", "selected");
		}
	});
	$(".currentYear option").each(function () {
		console.log(currentYear);
		if ($(this).val() == currentYear) {
			$(this).attr("selected", "selected");
		}
	});
});